package cn.itsource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = SpringConfig.class)
@RunWith(SpringRunner.class)
public class Send {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @Test
    public void testSendByTopics(){
        for (int i = 0; i < 20; i++) {
            String message = "就他妈你叫夏洛啊" + i;
            if (i%2 == 0){
                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "email.xxx", message);
                //System.out.println("消息发送成功'" + message + "email");
            }else {
                rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM, "sms.xxx", message);
               // System.out.println("消息发送成功'" + message + "sms");
            }

        }
    }
}
